Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ModMessageSystem #420

Merged

Conversation

LeeTwentyThree
Copy link
Member

Changes made in this pull request

  • Added a "mod message system" that allows for soft dependencies without assembly references and message-based APIs. Designed to work regardless of load order.

Breaking changes

  • None

@LeeTwentyThree
Copy link
Member Author

LeeTwentyThree commented Jun 26, 2023

The best way I could summarize this is "managed reflection". It's perfectly analogous to standard static method calling, but should be safer, easier and requires a very basic framework.

Here are some examples of adding compatibility to 4 (or more, because of that last overload) different mods with just single method calls:

ModMessageSystem.Send("GargantuanLeviathanMod", "AddGargantuanSpawn", new Vector3(1539, -602, 1200));

ModMessageSystem.Send("ArchitectsLibrary", "AddPrecursorFabricatorRecipe", ArchitectCatTechType, "AlienEquipment/Pets");
ModMessageSystem.Send("ArchitectsLibrary", "AllowInDisplayCase", ArchitectCatTechType);
ModMessageSystem.Send("ArchitectsLibrary", "SetScaleInDisplayCase", ArchitectCatTechType, 0.42069f);

ModMessageSystem.Send("EquivalentExchange", "AddValueForItem", ArchitectCatTechType, 600);

ModMessageSystem.Send("SeaVoyagerMod", "RegisterDockableVehicle", ArchitectCatTechType, false);

// this overload does *not* require an address, ONLY a subject:
// IDK if this is the best example, ngl. But maybe we could create standards/conventional message names that all vehicle/tools should use for things like this
ModMessageSystem.Send("RegisterToolBattery", NuclearBatteryByMetious);
ModMessageSystem.Send("RegisterVehicleBattery", NuclearPowerCellByMetious);

@LeeTwentyThree LeeTwentyThree merged commit cf62ca8 into SubnauticaModding:master Jun 27, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant